package com.sky.service.impl;

import com.sky.entity.Orders;
import com.sky.mapper.OrderMapper;
import com.sky.service.ReportService;
import com.sky.vo.TurnoverReportVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0.0
 * @program:sky-take-out
 * @author: CaoYuWei
 * @create:2023-02-11 14:33:53
 **/
@Service
@Slf4j
public class ReportServiceImpl /*implements ReportService*/ {
/*    @Autowired
    private OrderMapper orderMapper;

    *//**
     * 营业额统计图
     * @param begin
     * @param end
     * @return
     *//*
    @Override
    public TurnoverReportVO getTurnover(LocalDate begin, LocalDate end) {
        //根据时间区间统计营业额
        ArrayList<LocalDate> dateList = new ArrayList<>();
        dateList.add(begin);
        while (!begin.equals(end)){
            begin = begin.plusDays(1);
            dateList.add(begin);
        }
        ArrayList<Double> turnoverList = new ArrayList<>();
        for (LocalDate date : dateList) {
            LocalDateTime beginTime = LocalDateTime.of(date, LocalTime.MIN);
            LocalDateTime endTime = LocalDateTime.of(date, LocalTime.MAX);
            Map map = new HashMap();
            map.put("status", Orders.COMPLETED);//订单状态为已完成
            map.put("begin",beginTime);
            map.put("end",endTime);
            *//*Double turnover = orderMapper.sumByMap(map);*//*
           *//* turnoverList.add(turnover);*//*
        }
        TurnoverReportVO build = TurnoverReportVO.builder()
                .dateList(StringUtils.join(dateList, ","))
                .turnoverList(StringUtils.join(turnoverList, ","))
                .build();
        return build;
    }*/
}